package com.gis.premd;

import com.gis.beans;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * @author leon
 * @ClassName PreDriver.java
 * @createTime 2021年09月26日 12:32:00
 */
public class PreDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //1、新建Job
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        //2、设置jar包
        job.setJarByClass(PreDriver.class);

        //3、关联map和reduce关系
        job.setMapperClass(PreMapper.class);
        job.setReducerClass(PreReducer.class);

        //4、设置map的输出类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(beans.class);

        //5、设置最终的输出类型
        job.setOutputKeyClass(beans.class);
        job.setOutputValueClass(NullWritable.class);

        //6、设置输入输出路径
        FileInputFormat.setInputPaths(job,new Path("G:\\Design\\Huanghai\\onlyYantai2\\helfMonth.csv"));
        FileOutputFormat.setOutputPath(job,new Path("G:\\Design\\Huanghai\\preTreatment"));

        //7、提交job
        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0:1);
    }
}
